'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, DATE, STRING } = Sequelize;
    await queryInterface.createTable('api_logs', {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
      },
      method: {
        type: STRING(10),
        allowNull: false,
        comment: 'HTTP Method',
      },
      url: {
        type: STRING(255),
        allowNull: false,
        comment: 'Request URL',
      },
      status: {
        type: INTEGER,
        allowNull: false,
        comment: 'Response Status',
      },
      ip: {
        type: STRING(50),
        allowNull: false,
        comment: 'IP Address',
      },
      country: {
        type: STRING(50),
        allowNull: true,
        comment: 'Country',
      },
      response_time: {
        type: INTEGER,
        allowNull: false,
        comment: 'Response Time (ms)',
      },
      created_at: DATE,
      updated_at: DATE,
    });
  },

  down: async queryInterface => {
    await queryInterface.dropTable('api_logs');
  },
};
